package com.zzg.controller;

import com.zzg.entity.TmsUser;
import com.zzg.note.AdviceAnnotation;
import com.zzg.service.Impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * 控制器
 */
@Controller
public class MybatisController {

    @Autowired
    private UserServiceImpl userService;
    /**
     * 方法描述
     * @author zzg
     * @date 2021/6/18 8:57
     * @params *@params [password, username]
     * @return java.lang.String
     */
    @AdviceAnnotation(name = "进行登录验证")
    @RequestMapping(value = "/loginUser",produces = "text/html;charset=utf-8")
    @ResponseBody
    public String queryUserListTMS(String password, String username, HttpServletRequest request){
        System.out.println("进入："+password+"\t"+username);
        TmsUser login = userService.login(username, password);
        HttpSession session = request.getSession();
        if (login == null) {
            return "false";
        }else {
            //把姓名存到作用率
            session.setAttribute("TMS_User",login);
            return "true";
        }
    }




}


